//
//  BaseTableViewController.swift
//  SinaWeibo
//
//  Created by gaoliang on 15/11/10.
//  Copyright © 2015年 gaoliang. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorViewDelegate {

    // 添加用户是否登陆
    var userLogin =  UserAccountViewModel().userLogin
    var visitorView: VisitorView?
    override func loadView() {
        userLogin ? super.loadView() : loadVisitorView()
    }
    
    // 用户未登录进去访问界面
    private func loadVisitorView() {
        visitorView = VisitorView()
        // 设置代理
        visitorView?.visitorViewDelgate = self
        view = visitorView
        
        // 添加两个按钮
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "loginView")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "registerView")
    }
    
    func loginView() {
        print("come in")
        let aouth = OAuthViewcontroller()
        let nav = UINavigationController(rootViewController: aouth)
        presentViewController(nav, animated: true, completion: nil)
    }

    @objc func registerView() {
        print("come on")
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }

}
